
$(function () {

    // 最新资讯
    $.ajax({
        type: 'get',
        url: BigNew.index_latest,
        success(backData) {

            let resHtml = template('latestTem', backData);
            $('.common_news').html(resHtml);
            for (let i = 0; i < backData.data.length; i++) {

                $('.common_news_list>p').eq(i).html(backData.data[i].intro)
            }
        }
    });

    //最新评论
    $.ajax({
        type: 'get',
        url: BigNew.index_latest_comment,
        success(backData) {
            // console.log(backData);
            if (backData.code == 200) {
                let resHtml = template('commentTem', backData);
                $('.comment_list').html(resHtml)
            };
        },
    });

    //热点图
    $.ajax({
        type: 'get',
        url: BigNew.index_hotpic,
        success(backData) {
            // console.log(backData);
            if (backData.code == 200) {
                let resHtml = template('hotpicTem', backData);
                $('.focus_list').html(resHtml)
            };
        },
    });
    //文章热门排行
    $.ajax({
        type: 'get',
        url: BigNew.index_rank,
        success(backData) {
            if (backData.code == 200) {
                for (let i = 0; i < backData.data.length; i++) {
                    $('.hotrank_list li').eq(i).children('a').text(backData.data[i].title);
                    $('.hotrank_list li').eq(i).children('a').attr('href', './article.html?id=' + backData.data[i].id);
                };
            };

        },
    });


    //焦点关注
    $.ajax({
        type: 'get',
        url: BigNew.index_attention,
        success(backData) {
            // console.log(backData);
            if (backData.code == 200) {
                for (let i = 0; i < backData.data.length; i++) {
                    $('.guanzhu_list li').eq(i).children('a').text(backData.data[i].intro);
                    $('.guanzhu_list li').eq(i).children('a').attr('href', './article.html?id=' + backData.data[i].id);
                }

            };
        },
    });

    //文章类型 
    $.ajax({
        type: 'get',
        url: BigNew.index_category,
        success(backData) {
            if (backData.code == 200) {
                let resHtml = template('categoryTem', backData)
                $('.left_menu ').html(resHtml)
                $('.level_two ').html('<li class="up"></li>' + resHtml);

            };
        },
    });

    // 搜索
    $('.search_btn').click(function () {
        let key = $('.search_txt').val().trim();
        if (key == '') {
            alert('请输入内容');
            return
        }
        window.location.href = './list.html?seach=' + key;

    });











});














































